package com.hmkj.core.api.juhe.bean;


import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

/**
 * 描述: 调用接口返回参数封装类型
 * 作者: syx
 * 时间: 2016/11/29 14:27
 */
public class JuHeResult {

    private JSONObject attrs;
    private String json;
    private String params; //参数

    public JuHeResult(){}

    /**
     * 通过 json 构造 JuHeResult，注意返回结果不为 json 的 api（如果有的话）
     * @param jsonStr json结果
     */
    public JuHeResult(String jsonStr) {
        this.json = jsonStr;
        try {
            this.attrs = JSON.parseObject(json);
            this.error_code = attrs.getInteger("error_code");
            this.reason = attrs.getString("reason");
            this.result = attrs.getJSONObject("result");
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    /**
     * 返回码
     */
    private Integer error_code;

    /**
     * 返回说明
     */
    private String reason;

    /**
     * 返回的结果集
     */
    private JSONObject result;

    public Integer getError_code() {
        return error_code;
    }

    public void setError_code(Integer error_code) {
        this.error_code = error_code;
    }

    public String getReason() {
        return reason;
    }

    public void setReason(String reason) {
        this.reason = reason;
    }

    public JSONObject getResult() {
        return result;
    }

    public void setResult(JSONObject result) {
        this.result = result;
    }

    public JSONObject getAttrs() {
        return attrs;
    }

    public void setAttrs(JSONObject attrs) {
        this.attrs = attrs;
    }

    public String getJson() {
        return json;
    }

    public void setJson(String json) {
        this.json = json;
    }

    public String getParams() {
        return params;
    }

    public void setParams(String params) {
        this.params = params;
    }
}
